package com.song.guli.service.base.exception;

import com.song.guli.common.base.result.ResultCodeEnum;
import lombok.Data;
import lombok.ToString;

/**
 * @author 宋超
 * HP - the login name of the current user.
 * 2021/4/2 - the current system date.
 * 19:31 - the current system time.
 */
@Data
public class GuliException extends RuntimeException{
    //状态码
    private Integer code;

    /**
     * 接受状态码和消息
     * @param code
     * @param message
     */
    public GuliException(Integer code, String message) {
        super(message);
        this.code=code;
    }
    /**
     * 接收枚举类型
     * @param resultCodeEnum
     */
    public GuliException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }


    @Override
    public String toString() {
        return "GuliException{" +
        "code=" + code +
        ", message=" + this.getMessage() +
        '}';
    }

}
